package cn.com.ccxe.dao.parser;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import cn.com.ccxe.core.entity.Favorite;

public class FavoriteParser implements ResultSetParser<Favorite>{

	public List<Favorite> parse(ResultSet rs) throws SQLException {
		List<Favorite> favoriteWebsites = new ArrayList<Favorite>();
		while(rs.next()) {
			Favorite favoriteWebsite = parseObject(rs);
			if(favoriteWebsite != null) {
				favoriteWebsites.add(favoriteWebsite);
			}
		}
		return favoriteWebsites;
	}

	public Favorite parseObject(ResultSet rs) throws SQLException {
		Favorite favorite = new Favorite();
		favorite.setId(rs.getInt("id"));
		favorite.setMonitorTypeId(rs.getInt("monitorTypeId"));
		favorite.setIsStart(rs.getInt("isStart"));
		favorite.setType(rs.getString("type"));
		favorite.setPath(rs.getString("path"));
		favorite.setTitle(rs.getString("title"));
		favorite.setWebsiteTypeId(rs.getInt("websiteTypeId"));
		favorite.setWebsiteId(rs.getInt("websiteId"));
		return favorite;
	}

}
